package com.ttdc.service;

import java.util.Date;
import java.util.List;

import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import com.ttdc.mapper.OrderListMapper;
import com.ttdc.pojo.OrderList;
import com.ttdc.pojo.OrderListExample;

@Service
public class OrderListServiceImpl implements OrderListService {

	@Autowired
    private OrderListMapper orderListMapper;
	private OrderListExample example;
	
	private ApplicationContext applicationContext;
	
	@Before
	public void setUp() throws Exception {
		applicationContext = new ClassPathXmlApplicationContext("classpath:springmvc.xml");
		orderListMapper=(OrderListMapper) applicationContext.getBean("orderListMapper");
		example=new OrderListExample();
		
	}
	
	@Override
	public int countByExample(OrderListExample example) {
		return orderListMapper.countByExample(example); 
	}

	@Override
	public int deleteByExample(OrderListExample example) {
		return orderListMapper.deleteByExample(example);
	}

	@Override
	public int deleteByPrimaryKey(Integer olId) {
		return orderListMapper.deleteByPrimaryKey(olId);
	}

	@Override
	public int insert(OrderList record) {
		return orderListMapper.insert(record);
	}

	@Override
	public int insertSelective(OrderList record) {
		
		return orderListMapper.insertSelective(record);
	}

	@Override
	public List<OrderList> selectByExample(OrderListExample example) {
			//OrderListExample.Criteria criteria=example.createCriteria();
			//criteria.andOlIdIsNotNull();
			return orderListMapper.selectByExample(example);
	}

	@Override
	public List<OrderList> selectByAll() {
		return orderListMapper.selectByAll();
	}

	@Override
	public OrderList selectByPrimaryKey(Integer olId) {
		return orderListMapper.selectByPrimaryKey(olId);
	}

	@Override
	public int updateByExampleSelective(OrderList record, OrderListExample example) {
		return orderListMapper.updateByExampleSelective(record, example);
	}

	@Override
	public int updateByExample(OrderList record, OrderListExample example) {
		return orderListMapper.updateByExample(record, example);
	}

	@Override
	public int updateByPrimaryKeySelective(OrderList record) {
		return orderListMapper.updateByExampleSelective(record, example);
	}

	@Override
	public int updateByPrimaryKey(OrderList record) {
		System.out.println(record);
		return orderListMapper.updateByPrimaryKey(record);
	}

	@Override
	public List<OrderList> selectByDate(Date date) {
		OrderListExample example=new OrderListExample();
		OrderListExample.Criteria criteria=example.createCriteria();
		criteria.andOlDateEqualTo(date);
		return orderListMapper.selectByExample(example);
	}

}
